﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lm.Common.DAL;

namespace Lm.Common.Auth.Examples
{
    class Role
    {
        public void Add()
        {
            new Lm.Common.Auth.Role.RoleDraftEditor("8522dd1302274775a2f5b31141afa24a").Add
                (new Model.Role() { 
                 Pause=false, RoleCode="user", RoleName="useraaa", RoleStatus= Model.RoleStatus.Live.ToString(),
                });
        }

        public void Delete()
        {
            new Lm.Common.Auth.Role.RoleDraftEditor("8522dd1302274775a2f5b31141afa24a").RemoveRole("user");
        }

        public void Modify()
        {
            new Lm.Common.Auth.Role.RoleDraftEditor("8522dd1302274775a2f5b31141afa24a").EditRole(
                new Model.Role()
                {
                    Pause = true,
                    RoleCode = "user",
                    RoleId = new Guid(),
                    RoleName = "角色名2",
                    RoleRemark = "beizhu",
                    RoleStatus = Model.RoleStatus.Death.ToString()
                });
        }

        public void Select()
        {
            var list = new Lm.Common.Auth.Role.RoleSelector("8522dd1302274775a2f5b31141afa24a").GetRoleList(t => t.RoleName.ContainsSqlLike("a"));
        }

        public void Confirm()
        {
            new Lm.Common.Auth.Role.RoleAdmin("8522dd1302274775a2f5b31141afa24a").ConfirmRole("user");
        }

        public void KillRole()
        {
            new Lm.Common.Auth.Role.RoleAdmin("8522dd1302274775a2f5b31141afa24a").KillRole("user");
        }

        internal void ModifyLiveRole()
        {
            new Lm.Common.Auth.Role.RoleAdmin("8522dd1302274775a2f5b31141afa24a").EditRole(
                  new Model.Role()
                  {
                      Pause = true,
                      RoleCode = "user",
                      RoleId = new Guid(),
                      RoleName = "角色名3",
                      RoleRemark = "beizhu",
                      RoleStatus = Model.RoleStatus.Death.ToString()
                  }
                );
        }

        internal void Authorize()
        {
            //new Lm.Common.Auth.Role.RoleDraftEditor("8522dd1302274775a2f5b31141afa24a").Authorize("user", new Guid("{04A20F6B-4517-42F1-A663-372102522F98}"));

            new Lm.Common.Auth.Role.RoleAdmin("8522dd1302274775a2f5b31141afa24a").Authorize("user", new Guid("{04A20F6B-4517-42F1-A663-372102522F98}"));
        }
    }
}
